package com.baomidou.springwind.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.springwind.entity.Resource;
import com.baomidou.springwind.enums.ResourceEnum;
import com.baomidou.springwind.mapper.ResourceDao;
import com.baomidou.springwind.service.ResourceService;
import com.baomidou.springwind.service.support.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Resource 表数据服务层接口实现类
 */
@Service
public class ResourceServiceImpl extends BaseServiceImpl<ResourceDao, Resource> implements ResourceService {

    @Autowired
    private ResourceDao resourceDao;

    @Override
    public Resource getResource(Long batchId, ResourceEnum resEnum) {
        EntityWrapper<Resource> wrapper = new EntityWrapper<Resource>();
        wrapper.eq("batch_id", batchId);
        wrapper.eq("operator_id",getCurrentUserId());
        wrapper.eq("res_type", resEnum.getType());
        Resource resource = resourceDao.selectList(wrapper).get(0);
        return resource;
    }

    @Override
    public Long selectCompanyPersonCount(Long batchId) {
        return resourceDao.selectCompanyPersonCount(batchId);
    }
}